package com.ruoyi.web.users;


import java.util.ArrayList;
import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.users.vo.UStudyClockVo;
import com.ruoyi.users.vo.UUsersDetailVo;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.users.domain.UUsersDetail;
import com.ruoyi.users.service.IUUsersDetailService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 用户信息管理Controller
 *
 * @author yzc
 * @date 2024-12-03
 */
@RestController
@RequestMapping("/users/detail")
public class UUsersDetailController extends BaseController
{
    @Autowired
    private IUUsersDetailService uUsersDetailService;

    /**
     * 查询用户信息管理列表
     */
    @PreAuthorize("@ss.hasPermi('users:detail:list')")
    @GetMapping("/list")
    public TableDataInfo list(UUsersDetailVo uUsersDetailVo)
    {
        startPage();
//        List<UUsersDetail> list = uUsersDetailService.selectUUsersDetailList(uUsersDetail);
        List<UUsersDetailVo> uStudyClockVos = uUsersDetailService.selectall(uUsersDetailVo);
        return getDataTable(uStudyClockVos);
    }

    /**
     * 导出用户信息管理列表
     */
    @PreAuthorize("@ss.hasPermi('users:detail:export')")
    @Log(title = "用户信息管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, UUsersDetail uUsersDetail)
    {
        List<UUsersDetail> list = uUsersDetailService.selectUUsersDetailList(uUsersDetail);
        ExcelUtil<UUsersDetail> util = new ExcelUtil<UUsersDetail>(UUsersDetail.class);
        util.exportExcel(response, list, "用户信息管理数据");
    }

    /**
     * 获取用户信息管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('users:detail:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(uUsersDetailService.selectUUsersDetailById(id));
    }

    /**
     * 新增用户信息管理
     */
    @PreAuthorize("@ss.hasPermi('users:detail:add')")
    @Log(title = "用户信息管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody UUsersDetail uUsersDetail)
    {
        return toAjax(uUsersDetailService.insertUUsersDetail(uUsersDetail));
    }

    /**
     * 修改用户信息管理
     */
    @PreAuthorize("@ss.hasPermi('users:detail:edit')")
    @Log(title = "用户信息管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody UUsersDetail uUsersDetail)
    {
        return toAjax(uUsersDetailService.updateUUsersDetail(uUsersDetail));
    }

    /**
     * 删除用户信息管理
     */
    @PreAuthorize("@ss.hasPermi('users:detail:remove')")
    @Log(title = "用户信息管理", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(uUsersDetailService.deleteUUsersDetailByIds(ids));
    }
}
